import { GetCaseList, GetCaseCate } from "@/api";

export const useContent = () => {
    const tabList = ref([]);
    const tabActive = ref(0);
    const tabActive2 = ref(0);
    const list = ref([]);
    const name = "企业案例（PGC）";

    const tabList2 = computed(() => {
        return Array.isArray(list.value)
            ? list.value.map((item, index) => ({
                  label: item.name,
                  value: index,
              }))
            : [];
    });

    useSeoMeta({
        title: "Web3d展厅_AI数字人_3D云展会在线制作-北京华锐云空间",
        description:
            "华锐视点云空间具备强大的3D编辑能力，支持自主添加图片、文字、音视频、3D模型等，零代码创建一个可交互的3D云展空间，横跨Web、VR、手机多端口，助力企业创意营销升级。电话：13611042909",
        keywords: "虚拟展示,虚拟数字人,AI数字人,元宇宙,公司,3D展示",
    });

    watch(tabActive, () => {
        onGetCaseList();
    });

    const onGetCaseList = async () => {
        const res = await GetCaseList({
            cid: tabActive.value || "",
        });
        if (res.code == 200) {
            list.value = res.data;
        } else {
            Message().error(res.msg);
        }
    };

    const onGetCaseCate = async () => {
        const res = await GetCaseCate();
        if (res.code == 200) {
            tabList.value = [
                {
                    value: 0,
                    label: "全部",
                },
                ...res.data.map((item) => ({
                    label: item.name,
                    value: item.id,
                })),
            ];
        } else {
            Message().error(res.msg);
        }
    };

    return {
        tabList,
        tabList2,
        tabActive,
        tabActive2,
        list,
        name,
        onGetCaseList,
        onGetCaseCate,
    };
};
